using IoTCenter.Utilities.Models;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace Ganweisoft.IoTCenter.Module.MediaPlatform.Models
{
    public class OnvifDeviceListRequestModel
    {
        /// <summary>
        /// 本地ip
        /// </summary>
        [StringLength(15)]
        public string LocalIP { get; set; } = "192.168.0.207";
        /// <summary>
        /// 超时时间：单位(秒)
        /// </summary>
        public int Timeout { get; set; } = 5;
        /// <summary>
        /// 目标ip
        /// 组播：239.255.255.250
        /// </summary>
        [StringLength(15)]
        public string RemoteIP { get; set; } = "239.255.255.250";
    }

    public class OnvifDeviceCreateRequestModel
    {
        /// <summary>
        /// 本地ip
        /// </summary>
        [StringLength(15)]
        [Required]
        public string LocalIP { get; set; }

        /// <summary>
        /// onvif 用户名
        /// </summary>
        [StringLength(20)]
        [Required]
        public string UserName { get; set; }

        /// <summary>
        /// onvif 密码
        /// </summary>
        [StringLength(50)]
        [Required]
        public string Password { get; set; }

        /// <summary>
        /// 设备ip
        /// </summary>
        [Required]
        public IEnumerable<string> DeviceIps { get; set; }
    }

    public class OnvifDeviceCreateItemModel
    {
        public DeviceCreateRequestModel DeviceCreateRequest { get; set; }
        public DeviceStreamCreateRequestModel DeviceConfigCreateRequest { get; set; }
        public IList<NameValueObject> DeviceStreamUrls { get; set; }
    }
    public enum StreamTypes
    {
        /// <summary>
        /// 拉流
        /// </summary>
        [Description("拉流")]
        Pull = 10,
        /// <summary>
        /// 推流
        /// </summary>
        [Description("推流")]
        Push = 20
    }
    public class DeviceStreamCreateRequestModel
    {
        /// <summary>
        /// 拉/推流
        /// </summary>
        public StreamTypes StreamType { get; set; }
        /// <summary>
        /// 推拉流协议
        /// 拉流可用协议：rtmp、rtsp（优先支持）、http-ts、http-flv、his、http-mp4
        /// 推流可用可用：rtmp、rtsp、gb28181（优先支持）、webrtc、srt
        /// </summary>
        [StringLength(100)]
        [Required]
        public string Protocol { get; set; }
        /// <summary>
        /// 是否启用
        /// </summary>
        public bool Enabled { get; set; } = true;
        /// <summary>
        /// 设备拉流配置
        /// </summary>
        public DevicePullStreamParamModel PullParams { get; set; }
    }

    public class DevicePullStreamParamModel
    {
        /// <summary>
        /// 设备登录名
        /// </summary>
        [StringLength(100)]
        [Required]
        public string UserName { get; set; }
        /// <summary>
        /// 设备密码
        /// </summary>
        [StringLength(255)]
        [Required]
        public string Password { get; set; }
        /// <summary>
        /// 端口
        /// </summary>
        public int Port { get; set; }
    }
    public class DeviceCreateRequestModel
    {
        /// <summary>
        /// 设备名称
        /// </summary>
        [StringLength(100)]
        [Required]
        public string Name { get; set; }
        /// <summary>
        /// 品牌
        /// </summary>
        [StringLength(100)]
        public string Brand { get; set; }
        /// <summary>
        /// 型号
        /// </summary>
        [StringLength(100)]
        public string Model { get; set; }
        /// <summary>
        /// 摄像头IP地址
        /// </summary>
        [StringLength(15)]
        [Required]
        public string Ip { get; set; }
        /// <summary>
        /// 设备类型
        /// </summary>
        public DeviceTypes Type { get; set; }
        /// <summary>
        /// 设备分组id，可空
        /// </summary>
        public int? GroupId { get; set; }
        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; }
        /// <summary>
        /// ipc类型设备
        /// </summary>
        public CreateIPCModel Ipc { get; set; }
    }
    public enum DeviceTypes
    {
        Unknow = 0,
        IPC = 10,
        NVR = 20,
        Platform = 30
    }
    public enum DevicePTZControlTypes
    {
        GB28181 = 10,
        Onvif = 20
    }
    public class CreateIPCModel
    {
        /// <summary>
        /// 视频通道id(国标用，可空)
        /// </summary>
        [StringLength(255)]
        [Required]
        public string ChannelId { get; set; }
        /// <summary>
        /// 是否有ptz控制能力
        /// </summary>
        public DevicePTZControlTypes? PTZControl { get; set; }
        /// <summary>
        /// 通道推流配置
        /// </summary>
        public bool StreamPushEnabled { get; set; } = false;
    }

    public class OnvifDevicePTZControlRequestModel
    {
        /// <summary>
        /// 本地ip
        /// </summary>
        //[StringLength(15)]
        //[Required]
        //public string LocalIP { get; set; }

        /// <summary>
        /// onvif 用户名
        /// </summary>
        [StringLength(20)]
        [Required]
        public string UserName { get; set; }

        /// <summary>
        /// onvif 密码
        /// </summary>
        [StringLength(50)]
        [Required]
        public string Password { get; set; }

        /// <summary>
        /// 本地ip
        /// </summary>
        [StringLength(15)]
        [Required]
        public string RemoteIP { get; set; }
    }

    public class OnvifDevicePTZPresetGotoRequestModel
    {
        /// <summary>
        /// onvif 用户名
        /// </summary>
        [StringLength(20)]
        [Required]
        public string UserName { get; set; }

        /// <summary>
        /// onvif 密码
        /// </summary>
        [StringLength(50)]
        [Required]
        public string Password { get; set; }

        /// <summary>
        /// 本地ip
        /// </summary>
        [StringLength(15)]
        [Required]
        public string RemoteIP { get; set; }

        [StringLength(15)]
        [Required]
        public string PresetToken { get; set; }
    }

    public class OnvifDevicePTZPresetSetRequestModel
    {
        /// <summary>
        /// 本地ip
        /// </summary>
        //[StringLength(15)]
        //[Required]
        //public string LocalIP { get; set; }

        /// <summary>
        /// onvif 用户名
        /// </summary>
        [StringLength(20)]
        [Required]
        public string UserName { get; set; }

        /// <summary>
        /// onvif 密码
        /// </summary>
        [StringLength(50)]
        [Required]
        public string Password { get; set; }

        /// <summary>
        /// 本地ip
        /// </summary>
        [StringLength(15)]
        [Required]
        public string RemoteIP { get; set; }
        [StringLength(15)]
        [Required]
        public string PresetName { get; set; }
        public string PresetToken { get; set; }
    }

    public class OnvifDevicePTZPresetRemoveRequestModel
    {
        /// <summary>
        /// 本地ip
        /// </summary>
        //[StringLength(15)]
        //[Required]
        //public string LocalIP { get; set; }

        /// <summary>
        /// onvif 用户名
        /// </summary>
        [StringLength(20)]
        [Required]
        public string UserName { get; set; }

        /// <summary>
        /// onvif 密码
        /// </summary>
        [StringLength(50)]
        [Required]
        public string Password { get; set; }

        /// <summary>
        /// 本地ip
        /// </summary>
        [StringLength(15)]
        [Required]
        public string RemoteIP { get; set; }
        [StringLength(15)]
        [Required]
        public string PresetToken { get; set; }
    }
}
